#include "k210.h" 
#include "usart.h"	


int number1[8];
 extern int number;
int k210[11];

void k210_Recive(int data)
{
	u8 i;
	static u8 state = 0;
		
	if(state==0&&data==0xb3)
	{
		state = 1;
		k210[0] = data;
	}
	else if(state==1)
	{
		state = 2;
		k210[1] = data;
	}
	else if(state==2)
	{
		state = 3;
		k210[2] = data;
	}
	else if(state==3)
	{
		state = 4;
		k210[3] = data;
	}
	
		else if(state==4)
	{
		state = 5;
		k210[4] = data;
	}
		else if(state==5)
	{
		state = 6;
		k210[5] = data;
	}
		else if(state==6)
	{
		state = 7;
		k210[6] = data;
	}
		else if(state==7)
	{
		state = 8;
		k210[7] = data;
	}
		else if(state==8)
	{
		state = 9;
		k210[8] = data;
	}

	
	else if(state==9)
	{
		if(data == 0x5b)
		{
			state = 0;
			k210[9] = data;
		}
		else if(data != 0x5b)
		{
			state = 0;
			for(i=0;i<10;i++)
			{
				k210[i] = 0x00;
			}
		}
	}
	else
	{
		state = 0;
		for(i=0;i<10;i++)
		{
			k210[i] = 0x00;
		}
	}
	
}

void k210_data()
{
		
	number1[0]=k210[1];//1
	number1[1]=k210[2];//2
	number1[2]=k210[3];		
	number1[3]=k210[4];
	number1[4]=k210[5];
	number1[5]=k210[6];		
	number1[6]=k210[7];
	number1[7]=k210[8];

}







